package datetime

import (
	"time"
)

const formatStr = "2006-01-02 15:04:05"
const cstEastZone8FixedZone = 28800 //东8区偏移量,8*3600

//时间戳转时间格式
func Timestamp2Datetime(timestamp int64) string {
	return time.Unix(timestamp, 0).Format(formatStr)
}

//时间格式转东八区时间戳
func Datetime2TimestampPRC(datetime string) int64 {
	t, _ := time.ParseInLocation(formatStr, datetime, time.FixedZone("CST", cstEastZone8FixedZone))
	return t.Unix()
}

//时间格式转时间戳
func Datetime2Timestamp(datetime string, fixedZone int) int64 {
	t, _ := time.ParseInLocation(formatStr, datetime, time.FixedZone("CST", fixedZone))
	return t.Unix()
}
